﻿/*
 * ©2009-2010 XELF
 * http://xelf.info
 */

namespace XELF.Framework {

	public static partial class MathHelper {
		/// <summary>
		/// 算術平均 (a + b) / 2
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static float ArithmeticMean(float a, float b) {
			return (a + b) * 0.5f;
		}

		/// <summary>
		/// 幾何（相乗）平均 pow(a * b, 1 / n)
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static float GeometricMean(float a, float b) {
			return MathHelper.Sqrt(a * b);
		}

		/// <summary>
		/// 調和平均 2 / (1 / a + 1 / b)
		/// </summary>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <returns></returns>
		public static float HarmonicMean(float a, float b) {
			return MathHelper.Rcp(MathHelper.Rcp(a) + MathHelper.Rcp(b)) * 2;
		}

	}
}
